package com.yolo.util;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;

import java.util.UUID;

/**
 * ClassName: SmsUtil
 * Description:
 * date: 2021/4/19 15:34
 *
 * @author 须臾
 * @since JDK 1.8
 */
public class SmsUtil {

    public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret)
                .setEndpoint("dysmsapi.aliyuncs.com");
        return new Client(config);
    }

    public static String getUUIDCode() {
        Integer orderId = UUID.randomUUID().toString().hashCode();
        orderId = orderId < 0 ? -orderId : orderId;
        return orderId.toString().substring(0, 6);
    }
}
